<template>
  <el-container>
    <!-- 左侧 -->
    <el-aside :width="isCollapse ? '64px' : '200px'">
      <div class="toggle-button" @click="collapseList">|||</div>
      <el-menu
        default-active="1-4-1"
        class="el-menu-vertical-demo"
        @open="handleOpen"
        @close="handleClose"
        :collapse="isCollapse"
        background-color="#545c64"
        text-color="#fff"
        active-text-color="#ffd04b"
        :router="true"
      >
        <el-menu-item index="/welcome">
          <i class="el-icon-setting"></i>
          <span slot="title">首页</span>
        </el-menu-item>
        <el-submenu index="1">
          <template slot="title">
            <i class="el-icon-location"></i>
            <span slot="title">会员管理</span>
          </template>
          <el-menu-item-group>
            <el-menu-item index="/memberlist">会员列表</el-menu-item>
          </el-menu-item-group>
          <el-menu-item-group>
            <el-menu-item index="/labelmanage">标签管理</el-menu-item>
          </el-menu-item-group>
        </el-submenu>
        <el-menu-item index="/storelist">
          <i class="el-icon-menu"></i>
          <span slot="title">门店管理</span>
        </el-menu-item>
        <el-menu-item index="3" disabled>
          <i class="el-icon-document"></i>
          <span slot="title">导航三</span>
        </el-menu-item>
        <el-menu-item index="4">
          <i class="el-icon-setting"></i>
          <span slot="title">导航四</span>
        </el-menu-item>
      </el-menu>
    </el-aside>
    <!-- 中间 -->
    <center-element></center-element>
  </el-container>
</template>>

<script>
import { getMenu } from "network/menu.js";
import CenterElement from "./CenterElement";
export default {
  name: "LeftElementItem",
  components: {
    CenterElement,
  },
  data() {
    return {
      menuList: [],
      iconsObj: {
        125: "iconfont icon-users",
        103: "iconfont icon-tijikongjian",
        101: "iconfont icon-mima",
        102: "iconfont icon-pencil",
        145: "iconfont icon-baobiao",
      },
      //菜单是否收起
      isCollapse: false,
      //保存菜单点击高亮状态
      isHight: "",
    };
  },
  created() {
    // this.getMenuList();
    this.isHight = window.sessionStorage.getItem("activePath");
  },
  methods: {
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
    // 左侧菜单列表
    getMenuList() {
      getMenu().then(
        (res) => {
          const data = res.data;
          if (data.meta.status !== 200) {
            return this.$message.error(data.meta.msg);
          }
          this.menuList = data.data;
          console.log(this.menuList);
        },
        (err) => {
          console.log(err);
        }
      );
    },
    // 左侧菜单收起展示
    collapseList() {
      this.isCollapse = !this.isCollapse;
    },
    // 获取路径的值 并保存起来
    isHightClick(activePath) {
      window.sessionStorage.setItem("activePath", activePath);
      this.isHight = activePath;
    },
  },
};
</script>>

<style lang="less" >
.el-aside {
  background-color: rgb(84, 92, 100);
  .el-menu {
    border-right: none;
  }
}
.iconfont {
  margin-right: 5px;
}
#home .el-icon-menu {
  color: #fff;
}
.el-submenu .el-submenu__title i {
  color: #fff !important;
}
.toggle-button {
  width: 100%;
  line-height: 30px;
  background-color: rgb(84, 92, 100);
  color: #fff;
  text-align: center;
  letter-spacing: 0.2px;
  cursor: pointer;
}
.el-menu-item i {
  color: #fff;
}
</style>>